package edu.hwadee.BEIS.entity;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.springframework.format.annotation.DateTimeFormat;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;

/**
 * 开放填报实体类
 * 
 * @author kingsong
 *
 */
@Entity
@Table(name = "open_modify")
public class OpenModify implements java.io.Serializable {

	private Integer openModify_id;

	private Integer typeCode;

	@JSONField(format = "yyyy-MM-dd HH:mm:ss")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date startTime;

	@JSONField(format = "yyyy-MM-dd HH:mm:ss")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date endTime;

	private Set<SchoolUser> schoolUsers;

	public OpenModify() {

	}

	public OpenModify(Integer openModify_id, Integer typeCode, Date startTime, Date endTime,
			Set<SchoolUser> schoolUsers) {
		super();
		this.openModify_id = openModify_id;
		this.typeCode = typeCode;
		this.startTime = startTime;
		this.endTime = endTime;
		this.schoolUsers = schoolUsers;
	}

	@GenericGenerator(name = "generator", strategy = "increment")
	@Id
	@GeneratedValue(generator = "generator")

	@Column(name = "open_modify_id", unique = true, nullable = false)
	public Integer getOpenModify_id() {
		return openModify_id;
	}

	public void setOpenModify_id(Integer openModify_id) {
		this.openModify_id = openModify_id;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "open_modify_relationship", catalog = "beis", joinColumns = {
			@JoinColumn(name = "open_modify_id", nullable = false, updatable = false) }, inverseJoinColumns = {
					@JoinColumn(name = "school_user_id", nullable = false, updatable = false) })
	public Set<SchoolUser> getSchoolUsers() {
		return schoolUsers;
	}

	public void setSchoolUsers(Set<SchoolUser> schoolUsers) {
		this.schoolUsers = schoolUsers;
	}

	@Column(name = "type_code", nullable = false, length = 11)
	public Integer getTypeCode() {
		return typeCode;
	}

	public void setTypeCode(Integer typeCode) {
		this.typeCode = typeCode;
	}

	@Column(name = "start_time", nullable = false)
	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	@Column(name = "end_time", nullable = false)
	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	@Override
	public String toString() {
		return JSON.toJSONString(this);
	}

}
